package cn.jacksigxu.min3halla.block;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;

public class SmallIngredientCanBlock extends IngredientCanBlock {

    protected static final VoxelShape ONE_AABB = Block.box(5.0D, 0.0D, 5.0D, 11.0D, 11.0D, 11.0D);
    protected static final VoxelShape TWO_AABB_WE = Block.box(1.0D, 0.0D, 5.0D, 15.0D, 11.0D, 11.0D);
    protected static final VoxelShape TWO_AABB_NS = Block.box(5.0D, 0.0D, 1.0D, 11.0D, 11.0D, 15.0D);
    protected static final VoxelShape THREE_FOUR_AABB = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 11.0D, 15.0D);

    public SmallIngredientCanBlock() {
        super();
    }

    @Override
    public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
        return switch (pState.getValue(COUNT)) {
            case 1 -> ONE_AABB;
            case 2 -> {
                Direction direction = pState.getValue(FACING);
                if (direction.getAxis() == Direction.Axis.X) {
                    yield TWO_AABB_NS;
                } else {
                    yield TWO_AABB_WE;
                }
            }
            default -> THREE_FOUR_AABB;
        };
    }
}
